<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

const line = ref()

onMounted(() => {
  let myCharts = echarts.init(line.value)

  // 设置实例
  myCharts.setOption({
    xAxis:{
      type: 'category',
      boundaryGap: false, // 两侧是否留白
      splitLine: {
        show: false
      }, // 分割线
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    },
    yAxis:{
      splitLine: {
        show: false
      }// 分割线
    },
    grid: {
      top: 0,
      left: 40,
      bottom: 40,
      right: 0,
    },
    series: [
      {
        type: 'line',
        data: [120, 2240, 66, 99, 321, 100, 8],
        // 平滑曲线
        smooth: true,
        // 区域面积
        areaStyle: {
          color: 'red'
        }
      }
    ]
  })
})
</script>

<template>
  <div class="line">
    <div class="top">
      <p class="title">未来七天游客数量趋势</p>
      <p class="bg"></p>
    </div>

    <div class="charts" ref="line"></div>
  </div>
</template>

<style lang="scss" scoped>
.line {
  width: 100%;
  height: 100%;
  background: url('../../images/dataScreen-main-lb.png') no-repeat;
  background-size: 100% 100%;
  margin: 20px 0 0 20px;
  box-sizing: border-box;

  .top {
    margin-left: 20px;
    color: #fff;
    overflow: hidden;
    font-size: 20px;

    .bg {
      width: 68px;
      height: 7px;
      background: url('../../images/dataScreen-title.png') no-repeat;
      background-size: 100%;
      margin-top: 10px;
    }
  }

  .charts {
    height: calc(100% - 40px);
  }
}
</style>